<template>
  <div>
    <h1>登录</h1>
    <p>
      账 号：
      <input type="text" v-model="user.username" />
    </p>
    <p>
      密 码：
      <input type="text" v-model="user.password" />
    </p>
    <button @click="login">登录</button>
  </div>
</template>
  
  <script>
export default {
  data() {
    return {
      user: {
        username: "",
        password: "",
        sel:1
      }
    };
  },

  methods: {
    login() {
      if (!this.user.username || !this.user.password) {
        alert("请输入数据");
        return;
      }

      //admin，123
      if (this.user.username == "admin" && this.user.password == "123") {
        //本地存储
        localStorage.setItem("isLogin", "true");

        //跳转到首页
        this.$router.push("/index/home");
      } else {
        alert("账号或密码错误");
      }
    }
  }
};
</script>
  
  <style>
</style>